package com.net.xpay.backend.scheduler;


import com.net.xpay.common.domain.UserBusinessAuth;
import com.net.xpay.common.helper.NoticeHelper;
import com.net.xpay.common.manager.UserBusinessAuthManager;
import com.net.xpay.core.enums.UserBusinessAuthAuditStatus;
import com.net.xpay.core.model.AdminUserBusinesAuthSearchModel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 账号实名审核定时任务
 */
@Slf4j
@Component
public class UserBusinessAuthScheduler {

    @Autowired
    private UserBusinessAuthManager userBusinessAuthManager;

    @Autowired
    private NoticeHelper noticeHelper;

    /**
     * 检查实名认证状态
     */
    @Scheduled(cron = "0 */5 * * * *")
    public void checkSignAuth() {
        AdminUserBusinesAuthSearchModel searchModel = new AdminUserBusinesAuthSearchModel();
        searchModel.setUserBusinessAuthAuditStatus(UserBusinessAuthAuditStatus.AUDITING);
        List<UserBusinessAuth> batches = userBusinessAuthManager.list(searchModel);
        if (batches != null){
            for (UserBusinessAuth batch : batches) {
                noticeHelper.sendAuditNotice("账户企业实名认证有在审核中的用户，请及时审核："+batch.getId(), "text");
            }
        }
    }


}
